package com.atdel.demo27;


/**
 * @BelongsProject: java_study
 * @BelongsPackage: com.atdel.demo27
 * @Author: Del
 * @CreateTime: 2025-03-25  19:14
 * @Description: TODO
 * @Version: 1.0
 */
public class People<T extends Pet> {
    private String name;
    private T pet;

    public People() {
    }

    public People(String name, T pet) {
        this.name = name;
        this.pet = pet;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public T getPet() {
        return pet;
    }

    public void setPet(T pet) {
        this.pet = pet;
    }

    public void shopping() {
        System.out.print(this.name + "正在带着" + pet.getName() + "逛街\t");
        if (pet instanceof Callable) {
            ((Callable) pet).call();
        } else {
            System.out.println(pet.getName() + "很安静");
        }
    }

    public void show() {
        System.out.println(this.name + "养了一只" + this.pet.getClass().getSimpleName());
    }
}